package com.Util;

import com.Module.Boxnum;
import com.Module.Boxselect;

import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;

public class Window {
    public JFrame window(String window_name, int x, int y, int width, int heigth){
        JFrame jf = new JFrame(window_name);
        jf.setBounds(x,y,width,heigth);
        Toolkit kit = Toolkit.getDefaultToolkit();
        Dimension screenSize = kit.getScreenSize();
        int screenWidth = screenSize.width;
        int screenHeight = screenSize.height;
        jf.setLocation(screenWidth/2-width/2, screenHeight/2-heigth/2);
        jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        return jf;
    };
    public List<Boxnum> HorizontalBox(String title, int columns, int width){
        List<Boxnum> list=new ArrayList<>();
        Box box=Box.createHorizontalBox();
        JLabel jLabel=new JLabel(title);
        JTextField jTextField=new JTextField(columns);
        box.add(jLabel);
        box.add(Box.createHorizontalStrut(width));
        box.add(jTextField);
        Boxnum boxnum=new Boxnum(jTextField,box);
        list.add(boxnum);
        return  list;
    }
    public Box HorizontalBoxButton(String title, String title1,int width){
        Box box=Box.createHorizontalBox();
        JButton jButton=new JButton(title);
        JButton jButton1=new JButton(title1);
        box.add(jButton);
        box.add(Box.createHorizontalStrut(width));
        box.add(jButton1);
        return  box;
    }
    public List<Boxselect> HorizontalBox(String title, String[] items, int width){
        List<Boxselect> lis=new ArrayList<>();
        Box box=Box.createHorizontalBox();
        JLabel jLabel=new JLabel(title);
        JComboBox<String> jComboBox=new JComboBox<>(items);
        box.add(jLabel);
        box.add(Box.createHorizontalStrut(width));
        box.add(jComboBox);
        Boxselect boxselect=new Boxselect(box,jComboBox);
        lis.add(boxselect);
        return  lis;
    }
}
